package 实训二;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

public class IKTest {
    public static void main(String[] args) {
        List<String> list = ik("辉煌八维大数据");
        System.out.println(list);
    }
    public static List<String> ik(String str){
      List<String> list = new ArrayList<>();
        StringReader stringReader = new StringReader(str);
        IKSegmenter ik = new IKSegmenter(stringReader, true);
        try {
            Lexeme next = ik.next();
            while (next!=null){
                String text = next.getLexemeText();
                list.add(text);
                next = ik.next();
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return list;
    }
}
